<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 1400px;
            margin: 30px auto;
        }
        .box  a{
            display: block;
            width: 100px;
            height: 30px;
           
            float: left;
            text-align: center;
            line-height: 30px;
            text-decoration: none;
            background-color: blue;
            color: white;
            

        }




    </style>
</head>
<body>
    <div class="box"  id="d1">
    <a href="#">首页</a>
    <a href="#">国内</a>
    <a href="#">国际</a>
    <a href="#">军事</a>
    <a href="#">财经</a>

 <a href="#">娱乐</a>
 <a href="#">体育</a>
 <a href="#">互联网</a>
 <a href="#">科技</a>
 <a href="#">游戏</a>
 <a href="#">女人</a>
 <a href="#">汽车</a>
 <a href="#">房产</a>

</div>
  <script>


  var    as=  d1.children;
  for(var i=0;i<as.length;i++){
      as[i].onmouseover=function(){
          this.style.backgroundColor="red";

      }
      as[i].onmouseout=function(){
    this.style.backgroundColor="blue";
    } 


  }




  </script>




    
</body>
</html>